package com.itzhoun.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * topic主题交换机
 * @author 周楠
 * @Date 2022/07/19/下午 11:39
 */
@Configuration
public class TopicRabbitConfig {

    final static String woman = "topic.woman";

    final static String man = "topic.man";

    @Bean
    public Queue womanQueue(){
        return new Queue(TopicRabbitConfig.woman);
    }

    @Bean
    public Queue manQueue(){
        return new Queue(TopicRabbitConfig.man);
    }

    @Bean
    TopicExchange topicExchange(){
        return new TopicExchange("topicExchange");
    }

    @Bean
    Binding bindingMan(){
        return BindingBuilder.bind(manQueue()).to(topicExchange()).with(TopicRabbitConfig.man);
    }

    @Bean
    Binding bindingPerson(){
        return BindingBuilder.bind(womanQueue()).to(topicExchange()).with("topic.#");
    }
}
